package com.sky.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ArticleTagMapper {
    /**
     * 批量插入文章标签
     *
     * @param articleId
     * @param tagIds
     */
     void batchInsertArticleTag(Long articleId, List<Long> tagIds);

     /**
     * 根据文章id删除文章标签
     *
     * @param id
     */
     @Delete("delete from article_tag where article_id = #{id}")
    void deleteByArticleId(Long id);

     /**
     * 根据文章id查询标签id列表
     *
     * @param id
     * @return
     */
     @Select("select tag_id from article_tag where article_id = #{id}")
    List<Long> getTagIdsByArticleId(Long id);

     /**
     * 根据标签id查询文章id列表
     *
     * @param tagId
     * @return
     */
     @Select("select article_id from article_tag where tag_id = #{tagId}")
    List<Long> getArticleIdsByTagId(Long tagId);
}
